﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EKAABSInformationManagement.Service
{
    public class asyncSendingmail : IAsyncSendingmail
    {
        private delegate void sendingMail_del(string userName, string pwd, string serviceUri, string title, string mailBody, string to, string cc);
        private sendingMail_del sendingMail_m;
        private string userName = string.Empty;
        private string pwd = string.Empty;
        private string serviceUri = string.Empty;
        public string recipient { get; set; }
        public string ccRecipient { get; set; }
        public string mailBody { get; set; }
        public string mailSubject { get; set; }

        public asyncSendingmail()
        {
            this.userName = System.Configuration.ConfigurationSettings.AppSettings["userName"] == null ? "bochen" : System.Configuration.ConfigurationSettings.AppSettings["userName"].ToString();
            if (this.userName.Contains("@wicresoft.com") == false) this.userName += "@wicresoft.com";
            this.pwd = System.Configuration.ConfigurationSettings.AppSettings["password"] == null ? "p1Assw0rd!" : System.Configuration.ConfigurationSettings.AppSettings["password"].ToString();
            this.serviceUri = System.Configuration.ConfigurationSettings.AppSettings["serviceUri"] == null ? "https://mail.wicresoft.com/ews/exchange.asmx" : System.Configuration.ConfigurationSettings.AppSettings["serviceUri"].ToString();
            this.sendingMail_m = mailService.sendMail;
        }

        public void AsyncSendmail()
        {
            sendingMail_m.BeginInvoke(userName, pwd, serviceUri, mailSubject, mailBody, recipient, ccRecipient, null, null);
        }
    }
}
